<template>
  <div class="app-container">
    用户创建
    <el-form label-width="120px">
      <el-form-item label="合约地址">
        <el-input v-model="contractId"/>
      </el-form-item>
      <el-form-item label="合约名称">
        <el-input v-model="contractName"/>
      </el-form-item>
      <el-form-item label="用户名称">
        <el-input v-model="userNew.userName"/>
      </el-form-item>
      <el-form-item label="账户余额">
        <el-input v-model="userNew.balance"/>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="createUser()">保存</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
import user from '@/api/user'
export default {
  data() {
    return {
      userNew: {},
      contractName: '',
      contractId: ''
    }
  },
  created() {
  },
  methods: {
    // 添加
    createUser() {
      user.createUser(this.userNew, this.contractName, this.contractId)
        .then(response => {
          // 提示
          this.$message({
            type: 'success',
            message: '添加成功!'
          })
          // 跳转列表页面，使用路由跳转方式实现
          this.$router.push({ path: '/user/findAllUser' })
        })
    }
  }
}
</script>
